package com.studentstreet.tools;

import java.util.Comparator;

import com.studentstreet.entities.GoodsEntity;

public class SortByPrice implements Comparator {

	@Override
	public int compare(Object lhs, Object rhs) {
		GoodsEntity goods1 = (GoodsEntity) lhs;
		GoodsEntity goods2 = (GoodsEntity) rhs;
		if (goods1.getPrice() > goods2.getPrice())
			return 1;
		else if (goods1.getPrice() < goods2.getPrice()) {
			return -1;
		} else if (goods1.getPrice() == goods2.getPrice()) {
			return 0;
		}
		return goods1.getName().compareTo(goods2.getName());
	}

}
